$(function(){
	$('.adddepartment').on('click',function(){
		console.log(1)
		layer.open({
				type: 1,
				title: '添加部门',
				id: "delect" //防止重复弹出
					,
				content:`<div class='am-u-sm-12' style="padding-top:10px">
							<input type="text" name="number" value="{$item.number}" placeholder="部门名称" class="tpl-form-input am-u-sm-12 department_name" style="line-height: 21px;" />
						</div>`,
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					var department_name=$('.department_name')[0].value
					if($('.department_name')[0].value==""){
						layer.tips('内容不能为空', '.department_name', {tips: [2, 'red']});
					}
					Load()
					$.ajax({
						method:"POST",
						url:"{:url('department/add')}",
						data:{
							name:department_name,
							company_id:"{$Think.get.company_id}"
						},
						success:function(res){
							Load(1)
							console.log(res)
							if(res.code==1){
	
								var depm=`<tr data-id="${res.data}" data-useid="$item.car_use_id">
											<td>${department_name}</td>
											<td>
												<div class="tpl-table-black-operation">
													<a href="javascript:;" class="tpl-table-black-operation-del delete-list" data-method="delete">
														<i class="am-icon-pencil"></i> 删除
													</a>
												</div>
											</td>
										</tr>`
								$('tbody').html($('tbody').html()+depm)
								layer.closeAll();
							}else{
								
								layer.msg(res.msg);
							}
						},
						error:function(){
							Load(1)
							Err('请求失败')
						}
					});
				},
				btn2: function() {
					layer.closeAll();
				}
			});
	});
	$('.delete-list').on('click', function() {
		popup(this, "{:url('delete')}");

	});
	$('.keep1').on('click',function(){
		console.log(22)
	})
})
